package cn.edu.ujn.shi.service;

import cn.edu.ujn.shi.dao.AdminDto;
import cn.edu.ujn.shi.dao.AdminMapper;
import cn.edu.ujn.shi.dao.Admin;
import cn.edu.ujn.shi.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
public class AdminServiceImpl implements IAdminService {
    @Autowired
    AdminMapper adminMapper;

    @Autowired
    UserMapper userMapper;

    @Override
    public List<Admin> getAll() {
        return adminMapper.getAll();
    }


    @Override
    public List<Admin> getRepeat(Admin admin) {
        return adminMapper.getRepeat(admin);
    }

    @Override
    public void insert(Admin admin) {
        adminMapper.insert(admin);
    }

    @Override
    public void delete(String username) {
        adminMapper.delete(username);
    }

    @Override
    public List<Admin> getByUserName(String userName) {
        if (userName == null) {
            userName = "";
        }
        return adminMapper.getByUserName(userName);
    }

    @Override
    public void updateAdmin(AdminDto admin) {
        adminMapper.updateAdmin(admin);
    }
}
